﻿//PlazaConnection.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Plaza
{
	using System;
	using System.Threading;

	using Ecng.Common;

	using StockSharp.Plaza.Wrappers;

	class PlazaConnection
	{
		private Action _stopped;

		public PlazaConnection()
		{
			Runned = true;
		}

		public Thread Thread { get; set; }
		public bool Runned { get; private set; }

		public IConnectionWrapper NativeConnection { get; set; }

		public void Start()
		{
			Thread.Launch();
		}

		public void Stop(Action stopped)
		{
			if (stopped == null)
				throw new ArgumentNullException("stopped");

			_stopped = stopped;
			Runned = false;
		}

		public void RaiseStopped()
		{
			_stopped.SafeInvoke();
		}
	}
}